package day0720API;

public class Test1 {
    public static void main(String[] args) {
        String s="a";
        long  tt1=System.currentTimeMillis();
        for (int i = 0; i < 1000000; i++) {//3分钟出结果了
            s=s+"a";
        }
        long  tt2=System.currentTimeMillis();
        System.out.println("完毕"+(tt2-tt1));



        StringBuilder stringBuilder=new StringBuilder("a");
        long  t1=System.currentTimeMillis();
        //40毫秒出结果了, 原因是StringBuilder中操作的是同一个char数组
        for (int i = 0; i < 1000000; i++) {
            stringBuilder.append("a");
        }
        long  t2=System.currentTimeMillis();
        System.out.println("完毕"+(t2-t1));
    }
}